package com.booking.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.booking.bean.PageBean;
import com.booking.bean.Seller;
import com.booking.dao.SellerDAO;

@Service
public class SellerQueryServiceImpl implements com.booking.service.SellerQueryService {

	@Autowired
	private SellerDAO sellerDao;
	
	@Override
	public PageBean<Seller> findByPage(Integer currentPage,int pageSize) {
		
		PageBean<Seller> pageBean = new PageBean<Seller>();
        //总记录数
        int allRow = sellerDao.findCount();
        //当前页开始记录
        int offset = pageBean.countOffset(currentPage,pageSize);  
        //分页查询结果集
        List<Seller> list = sellerDao.findByPage(offset, pageSize); 

        pageBean.setPageNo(currentPage);
        pageBean.setPageSize(pageSize);
        pageBean.setTotalRecords(allRow);
        pageBean.setList(list);
        
		
		return pageBean;
	}

	@Override
	public  List<Seller> querySeller() {
		 List<Seller> seller = sellerDao.querySeller();
		return seller;
	}

}
